let BUS_CARD_INSTANCE = 'jhx_buscard' // 云卡卡实例

/**
 * 获取失败行程次数
 */
async function getUnpaySuccessCount() {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      // reject(new Error('fail', '111'))
      resolve(665)
    }, 50)
  })
}

// 以下都是测试数据
function getInstanceConfig() {
  return new Promise((resolve, reject) => {
    let body = {
      QRCODE_BALANCE_LIMIT: 0,
      RECHARGE_LIMIT: 1,
      LOW_BALANCE_DESC: 'http://www.baidu.com',
      QRCODR_POSBILL_LIMIT: 666
    }
    // return body
    resolve(body)
    reject(new Error('no config'))
  })
}
// 测试的扣款顺序
function getInstancePayOrder() {
  return new Promise((resolve, reject) => {
    let list = []
    for (let i = 0; i < 1; i++) {
      let payObj = {
        PAYMENT_ORDER_ID: '112',
        PAYMENT_NAME: i + '支付方式',
        BANK_CARD_SHORT_NO: '123' + i,
        PAY_ACCOUNT: '223' + i,
        PAYMENT: i === 0 ? 'ACCOUNT_PAY' : 'BINDCARD_PAY',
        // IS_SUPPORT: i !== 0 ? 1 : 0
        IS_SUPPORT: 1
      }
      list.push(payObj)
    }
    // let body = {
    //   LIST: list,
    //   COUNT: list.length
    // }
    // resolve(body)
    reject(new Error('no order'))
  })
}
function getWalletAmount() {
  return new Promise((resolve, reject) => {
    // reject(new Error('余额获取失败'))
    resolve({ BALANCE: 4 })
  })
}
function getCardList() {
  return new Promise((resolve, reject) => {
    let list = []
    for (let i = 0; i < 1; i++) {
      let cardInfo = {
        CARD_INSTANCE_ID: BUS_CARD_INSTANCE,
        CARD_TYPE: i,
        CARD_NAME: '电子市民卡' + i,
        STATE: 2,
        CARD_OWNER: '范颖莹',
        CARD_NO: '1234567890',
        AMOUNT: 8.5,
        FAIL_TIME: 2,
        FINAL_DISCOUNT: 80,
        SHOW_CARD_NO: '3301987654321001',
        DESC_GOTO: 'http://www.baidu.com',
        BACKGROUND_IMAGE: '',
        ICON: '',
        BACKGROUND_COLOR: ''
      }
      list.push(cardInfo)
    }
    let body = {
      COUNT: list.length,
      LIST: list
    }
    // return body
    setTimeout(() => {
      resolve(body)
    }, 200)
  })
}

export {
  getUnpaySuccessCount,
  getCardList,
  getInstanceConfig,
  getInstancePayOrder,
  getWalletAmount
}
